<template>
  <div>
    <div class="header">
      <div class="container">
        <div class="clearfix">
          <router-link to="/index" class="bl logo fl"
            ><img src="../img/logp.svg" alt=""
          /></router-link>
          <div class="fr login_res">
            <div v-if="!token">
              <router-link to="/login">登录</router-link> |
              <router-link to="/register">注册</router-link>
            </div>
            <div v-else>
              你好，
              <router-link to="/dashboard">会员中心</router-link>
            </div>
          </div>
          <div @click="see()" class="fr lanuage">
            <i class="iconfont icon-yuyan"></i>EN
          </div>
          <router-link to="/stroylist" class="our_story bl fr"
            >我们的故事</router-link
          >
          <div class="fr search-box">
            <select class="fl sel" id="headSearchSelect" v-model="headType">
              <option value="">热门活动</option>
              <option value="1">热门团队</option>
            </select>
            <div class="fl clearfix sex-b">
              <input
                v-model="headKeyword"
                id="headKeyword"
                value=""
                placeholder="每天都有人在寻找活动"
              />
              <button type="button" @click="headSearch()">
                <i class="iconfont icon-sousuo"></i>
              </button>
            </div>
          </div>
          <div class="nav_ul fr">
            <ul class="clearfix">
              <li>
                <router-link exact to="/index" class="bl">首页</router-link>
              </li>
              <li>
                <router-link
                  to="/hotlist"
                  class="bl active"
                  v-if="this.url.indexOf('hotshow') !== -1"
                  >热门活动</router-link
                >
                <router-link to="/hotlist" class="bl" v-else
                  >热门活动</router-link
                >
              </li>
              <li>
                <router-link
                  to="/hotteamlist"
                  class="bl active"
                  v-if="this.url.indexOf('hotteamshow') !== -1"
                  >热门团队</router-link
                >
                <router-link to="/hotteamlist" class="bl" v-else
                  >热门团队</router-link
                >
              </li>
              <li>
                <router-link to="/release" target="_blank" class="bl">创建活动</router-link>
              </li>
              <li>
                <router-link to="/create" target="_blank" class="bl">创建团队</router-link>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="phone_header">
      <div class="container">
        <div class="clearfix">
          <div class="fl" @click="showPhoneMneu">
            <i class="iconfont icon-ego-menu"></i>
          </div>
          <div class="fr">
            <div class="fr login_res">
              <div v-if="!token">
                <router-link to="/login">登录</router-link> |
                <router-link to="/register">注册</router-link>
              </div>
              <div v-else>
                你好，
                <router-link to="/dashboard">会员中心</router-link>
              </div>
            </div>
          </div>
          <div class="ta top">
            <router-link to="/index" class="ta"
              ><img src="../img/logp.svg" class="phone_logo" alt=""
            /></router-link>
          </div>
        </div>
      </div>
    </div>
    <!-- 手机端菜单 -->
    <div class="phonemenu" v-show="isShow">
      <div class="container">
        <div class="top clearfix">
          <div class="fl">
            <router-link to="/index" class="ta"
              ><img src="../img/logp.svg" class="phone_logo" alt=""
            /></router-link>
          </div>
          <div class="fr" @click="hidePhoneMneu">
            <i class="iconfont icon-guanbi"></i>
          </div>
        </div>
        <ul class="clearfix">
          <li>
            <router-link exact to="/index" class="bl">首页</router-link>
          </li>
          <li>
            <router-link
              to="/hotlist"
              class="bl active"
              v-if="this.url.indexOf('hotshow') !== -1"
              >热门活动</router-link
            >
            <router-link to="/hotlist" class="bl" v-else>热门活动</router-link>
          </li>
          <li>
            <router-link
              to="/hotteamlist"
              class="bl active"
              v-if="this.url.indexOf('hotteamshow') !== -1"
              >热门团队</router-link
            >
            <router-link to="/hotteamlist" class="bl" v-else
              >热门团队</router-link
            >
          </li>
          <li>
            <router-link exact to="/stroylist" class="bl">我们的故事</router-link>
          </li>
          <li>
            <router-link to="/dashboard" class="bl">创建活动</router-link>
          </li>
          <li>
            <router-link to="/details" class="bl">创建团队</router-link>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      keyword: this.$route.query.keyword,
      headKeyword: "",
      headType: "",
      token: "",
      url: "",
      isShow: false,
    };
  },
  methods: {
    showPhoneMneu: function () {
      this.isShow = !this.isShow;
    },
    hidePhoneMneu: function () {
      this.isShow = !this.isShow;
    },
    see() {
      //加上这个便可以跳转啦
      //打开新的标签页
      window.open("/index");
    },
    headSearch() {
      console.log('search',this.headKeyword);
      if (this.headType == 1) {
        this.$router.push({
          path: "/hotteamlist",
          query: { keyword: this.headKeyword },
        });
      } else {
        this.$router.push({
          path: "/hotlist",
          query: { keyword: this.headKeyword },
        });
      }
    },
  },
  mounted() {
    this.token = window.localStorage.getItem("token");
    this.url = window.location.href;
    //console.log("t", this.token);
    //console.log(this.url);

    this.headKeyword = '';
    if (this.keyword) {
      this.headKeyword = this.keyword;
      document.title = this.headKeyword + "-聚聚阿米奇";
    }
  },
  watch: {
    $route (to, from) {
      // to表示要跳转的路由，from表示从哪儿跳的路由   to.path
      this.$router.go(0)
    },
  },
};
</script>

<style  scoped>
.phone_header {
  display: none;
}
.login_res > div {
  display: inline;
  background-color: #ffce45;
  padding: 0.625rem 0.875rem;
  border-radius: 0.1875rem;
  font-size: 0.875rem;
}

.login_res a {
  color: #3d3d3d;
  position: relative;
  display: inline-block;
}

.login_res a:hover {
  color: #fff;
}

.header {
  line-height: 4.75rem;
  background-color: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  border-bottom: 1px solid #ddd;
}
.header .lanuage {
  margin: 0 1.875rem 0 0;
  font-size: 1rem;
  color: #3d3d3d;
  cursor: pointer;
}
.header .lanuage {
  color: #3d3d3d;
}
.header .lanuage i {
  font-size: 1rem;
  margin-right: 0.375rem;
}
.header .lanuage:hover {
  color: #4c8bf5;
}
.header .our_story {
  font-size: 1rem;
  color: #3d3d3d;
  margin: 0 1.875rem;
  display: block;
}

.header .our_story:hover {
  color: #4c8bf5;
}

.header .search-box {
  width: 18.75rem;
  height: 2.5rem;
  line-height: 2.1875rem;
  position: relative;
  top: 1.25rem;
  display: inline-block;
  border-radius: 5px;
  border: solid 1px #e1e1e1;
}

.header .search-box form {
  width: 100%;
}

.header .search-box .sel {
  border: none;
  font-size: 0.8125rem;
  color: #3d3d3d;
  height: 2.375rem;
  width: 30%;
  appearance: none;
  padding: 0 0.625rem;
  -moz-appearance: none;
  -webkit-appearance: none;
  background: url(../img/img/xl.png) no-repeat right center;
  border-right: 1px solid #e1e1e1;
  background-position-x: 4.25rem;
  font-size: 0.75rem;
}

.header .search-box .sel::-ms-expand {
  display: none;
}
.header .logo img {
  width: 9.625rem;
}

.header .search-box .sex-b {
  width: 70%;
  position: relative;
}

.header .search-box .sex-b input {
  width: 80%;
  height: 2.375rem;
  float: left;
  background: transparent;
  padding-left: 10px;
  font-size: 0.8125rem;
  /* color: #c7c7c7; */
  color: #585858;
  border: none;
}
.header .search-box .sex-b input::-webkit-input-placeholder {
  color: #c7c7c7;
}

.header .search-box .sex-b input::-moz-placeholder {
  color: #c7c7c7;
}

.header .search-box .sex-b input:-ms-placeholder {
  color: #c7c7c7;
}
.header .search-box .sex-b button {
  height: 2.375rem;
  width: 20%;
  float: left;
  background-color: #f8f8f8;
  border-radius: 0px 3px 3px 0px;
  border: none;
  line-height: 2.1875rem;
  text-align: center;
}

.header .search-box .sex-b button i {
  color: #3d3d3d;
  font-size: 1rem;
}

.header .nav_ul {
  margin-right: 3.125rem;
}

.header .nav_ul > ul > li {
  float: left;
  padding: 0 0.875rem;
}

.header .nav_ul > ul > li > a {
  position: relative;
  padding: 0 0.4375rem;
  font-size: 1rem;
  color: #3d3d3d;
}

.header .nav_ul > ul > li:hover > a,
.header .nav_ul > ul > li > a.active {
  color: #de5044;
}

.header .nav_ul > ul > li:hover a::before,
.header .nav_ul > ul > li a.active::before {
  transition: all 0.4s;
  -webkit-transform: all 0.4s;
  -moz-transition: all 0.4s;
  -o-transition: all 0.4s;
  width: 100%;
}

.header .nav_ul > ul > li a::before,
.header .nav_ul > ul > li a::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background-color: #de5044;
}

@media (max-width: 1440px) {
  .header .search-box .sel {
    background-position-x: 4.6rem;
  }
}

@media (max-width: 1280px) {
  .header .nav_ul > ul > li > a {
    font-size: 14px;
  }
  .header .lanuage {
    margin-right: 15px;
    font-size: 14px;
  }
  .header .nav_ul {
    margin-right: 20px;
  }
  .header .our_story {
    font-size: 14px;
    margin: 0 15px;
  }
  .header .search-box .sel {
    width: 35%;
  }
  .header .search-box .sex-b {
    width: 65%;
  }
  .header .nav_ul > ul > li > a {
    padding: 0;
  }
  .header .search-box {
    width: 21rem;
  }
  .header .search-box .sel {
    background-position-x: 6rem;
  }
}
@media (max-width: 1100px) {
  .header .nav_ul {
    margin-right: 5px;
  }
  .header .our_story {
    margin: 0 10px;
  }
  .header .nav_ul > ul > li {
    padding: 0 5px;
  }
}
@media (max-width: 1024px) {
  .header .nav_ul > ul > li {
    padding: 0 5px;
  }
}
@media (max-width: 990px) {
  .phone_header {
    line-height: 60px;
    display: block;
    position: fixed;
    top: 0;
    left: 0%;
    width: 100%;
    z-index: 9900;
    box-shadow: 0 0 3px #ddd;
    background: #fff;
  }

  .phone_logo {
    height: 40px;
  }
  .phone_logo img {
    display: inline-block;
  }
  .phone_header .top {
    margin: 0 auto;
  }
  .phone_header .iconfont {
    font-size: 24px;
    display: block;
  }
  .phone_header .container > .clearfix > .fl {
    width: 30%;
  }
  .phone_header .container > .clearfix > .fr {
    width: 30%;
  }
  .phone_header .container > .clearfix > .top {
    width: 40%;
  }
  .phonemenu {
    position: fixed;
    left: 0;
    background: #fff;
    width: 100%;
    height: 100%;
    z-index: 9999;
    left: 0;
    top: 0;
    overflow: auto;
    overflow-x: hidden;
    transition: top ease 0.35s;
  }
  .phonemenu.active {
    top: 0;
    transition: top ease 0.35s;
  }
  .phonemenu .top {
    padding: 10px 0;
    line-height: 40px;
    border-bottom: 1px solid #ddd;
  }
  .phonemenu .top img {
    height: 40px;
  }
  .phonemenu .top .iconfont {
    display: block;
  }
  .phonemenu ul li {
    line-height: 50px;
    border-bottom: 1px solid #ddd;
  }
  .phonemenu ul li a {
    font-size: 14px;
    color: #767676;
  }
}
@media (max-width: 767px) {
  .phone_header .container > .clearfix > .fl {
    width: 35%;
  }
  .phone_header .container > .clearfix > .fr {
    width: 35%;
  }
  .phone_header .container > .clearfix > .top {
    width: 30%;
  }
  .login_res > div {
    padding: 10px 5px;
    font-size: 12px;
  }
}
</style>
